package com.akkainaction.router.group.actor;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.FromConfig;

public class MasterActor extends UntypedActor {

    ActorRef router;

    @Override
    public void preStart() throws Exception {
        getContext().actorOf(Props.create(WorkTaskActor.class), "wk1");
        getContext().actorOf(Props.create(WorkTaskActor.class), "wk2");
        getContext().actorOf(Props.create(WorkTaskActor.class), "wk3");
        router = getContext().actorOf(FromConfig.getInstance().props(), "router");
    }

    @Override
    public void onReceive(Object msg) throws Exception {
        router.tell(msg, getSelf());
    }
}
